
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        .container {
            display: flex;
            justify-content: space-between;
        }

        .left {
            width: 48%;
            font-size: 24px;
        }

        .right {
            width: 48%;
        }
    </style>
</head>
<body>
<c:if test="${user!=null}">
    <div class="container" >
        <span class="left">${user.username},欢迎登录</span> <div class="right"><input value="注销" type="button" id="logout_bt"></div>
    </div>
</c:if>

<input type="button" value="新增" id="add"><br>
<table border="1" cellspacing="0" width="80%">
    <tr>
        <th>序号</th>
        <th>品牌名称</th>
        <th>企业名称</th>
        <th>排序</th>
        <th>品牌介绍</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${brands}" var="brand" varStatus="status">
        <tr align="center">
            <td>${status.count}</td>
            <td>${brand.brandName}</td>
            <td>${brand.companyName}</td>
            <td>${brand.ordered}</td>
            <td>${brand.description}</td>
            <c:if test="${brand.status==1}">
                <td>启用</td>
            </c:if>
            <c:if test="${brand.status != 1}">
                <td>禁用</td>
            </c:if>
            <td><a href="/kw12_d1_mvc_project_war/selectByIdServlet?id=${brand.id}">修改</a>
                <a href="/kw12_d1_mvc_project_war/deleteByIdServlet?id=${brand.id}">删除</a>
        </tr>
    </c:forEach>

</table>

<script>
    //点击新增按钮 跳转到添加的界面
    document.getElementById("add").onclick = function (){
        location.href = "/kw12_d1_mvc_project_war/addBrand.jsp";
    }

    //点击注销按钮，跳转到logout的servlet
    document.getElementById("logout_bt").onclick=function (){
        location.href = "/kw12_d1_mvc_project_war/logoutServlet";
    }
</script>
</body>
</html>
